asp.net MVC

Unable to retrieve metadata for ‘models.classname’. unable to cast object of type System.Data.Entity.Core.Objects.ObjectContext to type System.Data.Objects.ObjectContext.

Unable to retrieve metadata for ‘models.classname’. unable to cast object of type System.Data.Entity.Core.Objects.ObjectContext to type System.Data.Objects.ObjectContext., someone asked me to explain?

Entity framework 6 or above version is not supported for asp.net MVC. So we need to uninstall it by using Package manager console.

Uninstall-Package EntityFramework –Version 6.0.0

If it is uninstalled then install entity framework 5.

If you are unable uninstall then I recommended you to delete the following entity framework version 6.0.0 reference from package.config.

<package id="EntityFramework" version="6.0.0" targetFramework="net45" />

Again install entity framework 5 by running the following command in the Package Manager Console

 

PM> Install-Package EntityFramework –Version 5.0.0.0

Install-Package EntityFramework 5

 

 

Post your comments / questions